import { request } from "@/utils/requests"
import type * as Login from "./types/login"

/** 登录并返回 Token */
export function loginApi(data: Login.ILoginRequestData) {
    return request<Login.LoginResponseData>({
      url: "users/login",
      method: "post",
      data
    })
  }
  
  /** 获取用户详情 */
  export function getUserInfoApi(u_id:{u_id:string}) {
    return request<Login.UserInfoResponseData>({
      url: "users/info",
      method: "get",
      params:u_id
    })
  }
// 获取用户所有的列表
export function getUserList<T>(params:T){
  return request<Login.AllUserListResponseData>({
    url: "users/list",
    method: "get",
    params,
  })
}

// 获取权限列表
export function getRolesList<T>(params:T){
  return request<Login.RolesListResponseData>({
    url: "roles/list",
    method: "get",
    params,
  })
}

  // 获取用户权限
 export function  getUserRolesApi(data:{u_id:string}){

    return request<Login.RolesResponseData>({
      url: "users/roles",
      method: "post",
      data
    })
 }